package vn.gg.network;

import org.apache.mina.core.service.IoHandler;
import org.apache.mina.core.session.IdleStatus;
import org.apache.mina.core.session.IoSession;

import vn.gg.util.Log;

public class MinaInput implements IoHandler {

	final static String TAG = "MINA Input";
	
	@Override
	public void exceptionCaught(IoSession arg0, Throwable arg1)
			throws Exception {
		
		
	}

	@Override
	public void messageReceived(IoSession session, Object message) throws Exception {
		Log.log(TAG, "messageReceived");
		Message m = new Message("HEHE", "HIHI");
		session.write(m);
		
		m = new Message("HEHE1", "HIHI1");
		session.write(m);
		
		m = new Message("HEHE2", "HIHI2");
		session.write(m);
	}

	@Override
	public void messageSent(IoSession session, Object arg1) throws Exception {
		Log.log(TAG, "messageSent on Thread: " + Thread.currentThread().getId());
		//Message m = new Message("HEHE2", "HIHI2");
		//session.write(m);
	}

	@Override
	public void sessionClosed(IoSession arg0) throws Exception {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void sessionCreated(IoSession session) throws Exception {
		Log.log(TAG, "sessionCreated on Thread: " + Thread.currentThread().getId());
	}

	@Override
	public void sessionIdle(IoSession arg0, IdleStatus arg1) throws Exception {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void sessionOpened(IoSession arg0) throws Exception {
		// TODO Auto-generated method stub
		
	}

}
